package com.itheima.array;

import java.util.Scanner;

/**
 * @Author 王加鑫
 * @Date 2021/4/20 19:01
 * @Version 1.0
 * 评委打分
 */
public class arrayTest07 {
    public static void main(String[] args) {
        //定义接收键盘数据
        Scanner sc = new Scanner(System.in);
        //六个评委,动态定义数组
        int[] arr = new int[6];
        //遍历数组
        for (int i = 0; i < arr.length; i++) {
            System.out.println("请输入第"+(i+1)+"评委的评分:");
            //定义变量接收键盘录入的数据
            int score = sc.nextInt();
            //判断语句,评委评分只能在1-100分之内
            if(score >= 1 && score<=100){
                arr[i] = score;
            }else {
                System.out.println("输入有误,请重新输入");
                i--;
            }
        }

        //找出数组最大值
        int max = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] > max){
                max = arr[i];
            }
        }
        System.out.println("评委最高分是:"+max);


        //找出数组最小值
        int min = arr[0];
        for (int i = 0; i < arr.length; i++) {
            if(arr[i] < min){
                min = arr[i];
            }
        }
        System.out.println("评委最低分是:"+min);

        //求评委评分总和
        int sum = 0;
        for (int i = 0; i < arr.length; i++) {
            sum+=arr[i];
        }
        System.out.println("评委评分总和是:"+sum);

        //去掉一个最低分,去掉一个最高分,求平均值
        int avg = (sum - max - min)/(arr.length - 2);
        System.out.println("评委平均分是:"+avg);
    }
}
